package org.nanotek.lucene.index;

import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.UUID;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.core.StopAnalyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.Version;
import org.nanotek.indexer.util.key.KeyServiceFactory;
import org.nanotek.indexer.util.key.KeyServiceFactoryException;

/**
 * @deprecated
 * @author josecanovamauger.
 *
 */
public class IndexSet implements IndexBaseSet<UUID> {

	private SortedMap<UUID, IndexWriter> indexMap; 
//	private final String indexPath = Messages.getString("FileIndexer.IndexBaseLocation");

	public IndexSet() { 
		indexMap = Collections.synchronizedSortedMap(new TreeMap<UUID,IndexWriter>());
	}

	/*
	 * TODO - Finish key service objects. 
	 */
	public UUID getNextKey() throws KeyServiceFactoryException {
		return (UUID) new KeyServiceFactory().getKey(UUID.class);
	}

	public IndexWriter get(UUID key) {
		return indexMap.get(key);
	}

	public IndexWriter put(UUID  key, IndexWriter value) {
		return indexMap.put(key, value);
	}

	public IndexWriter remove(UUID key) {
		return indexMap.remove(key);
	}

	public void closeIndexes() {
		for (Map.Entry<UUID,IndexWriter> entry: indexMap.entrySet()){ 
			IndexWriter writer = entry.getValue();
			try { 
				writer.close();
			}catch (Exception ex){}
		}
	}
}

